#!/bin/bash

CG=$1

path=/sys/fs/cgroup/cpu/${CG}

echo $path

old=$(< ${path}/cpuacct.usage)
while true
do
        now=$(< ${path}/cpuacct.usage)

        delta=$(echo "$now - $old" | bc)

        usage=$(echo "scale=2; $delta * 100 / 1000000000" | bc)
        echo "CPU usage: ${usage}%"
        old=$now

        sleep 1
done

